//
// Created by ashCheng on 2023/2/4.
//
#include <iostream>
#include <string>
#include "Sales_data.h"

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

int main() {
  Sales_data data1, data2;
  double price1, price2;
  cin >> data1.bookNo >> data1.units_sold >> price1;
  cin >> data2.bookNo >> data2.units_sold >> price2;
  data1.revenue = data1.units_sold * price1;
  data2.revenue = data2.units_sold * price2;

  if (data1.bookNo == data2.bookNo) {
    unsigned total_cnt = data1.units_sold + data2.units_sold;
    double total_revenue = data1.revenue + data2.revenue;
    cout << data1.bookNo << " " << total_cnt << " " << total_revenue << " ";
    if (total_cnt != 0) {
      cout << total_revenue / total_cnt << endl;
    } else {
      cout << "No sales!" << endl;
    }
    return 0;
  } else {
    cerr << "Data must refer to same ISBN" << endl;
    return -1;  // indicate failure
  }
}